-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EventHub client extension methodS #7034
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor suggestion, but that may be based on an incorrect assumption. Otherwise, LGTM!
@@ -8,6 +8,6 @@ namespace Azure.Core.Extensions | |||
{ | |||
public interface IAzureClientFactoryBuilder | |||
{ | |||
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TClient> clientFactory) where TOptions : ClientOptions; | |||
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TClient> clientFactory) where TOptions : class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making the options always have a default constructor and using that constraint, or is that unimportant down the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, they almost never have a default constructor. Instead, the guidelines prescribe having a constructor with ServiceVersion parameter defaulted to latest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. Forgot about that due to the deviation in the Event Hubs service design.
/// <summary> | ||
/// Registers a <see cref="EventHubClient"/> instance with the provided <paramref name="connectionString"/> and <paramref name="eventHubPath"/> | ||
/// </summary> | ||
public static IAzureClientBuilder<EventHubClient, EventHubClientOptions> AddEventHubClient<TBuilder>(this TBuilder builder, string connectionString, string eventHubPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may not have context enough to be reading this entirely correctly, but I believe this limits scenarios to:
- Here's a connection string (with path embedded) and a set of options
- Here's a connection string and an event hub path, but you have to use default options (I suspect this will be the majority case)
If that is the case, I'd suggest that we also allow:
- Here's a connection string, event hub path, and set of options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IAzureClientBuilder
return type has a ConfigureOptions(options => {}) method on it.
So to add a client and configure its options:
builder.AddEventHubClient("connectionString", "path").ConfigureOptions(options => {} );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Works for me!
Also adjust IAzureClientFactoryBuilderWithCredential type name.